package com.yhuso.study.studyAkkaForActor;

import com.yhuso.study.studyAkkaForActor.Greeter.Msg;

import akka.actor.ActorRef;
import akka.actor.Props;
import akka.actor.UntypedActor;

public class HelloWorld extends UntypedActor {
	
	//启动时调用
	@Override
	public void preStart() {
		final ActorRef greeter = getContext().actorOf(Props.apply(Greeter.class), "greeter");
		greeter.tell(Msg.GREET, getSelf());
	};
	
	@Override
	public void onReceive(Object msg) throws Exception {
		if(Msg.DONE == msg){
			getContext().stop(getSelf());
		}else{
			unhandled(msg);
		}
			
	}

}
